package com.tzs.config;

import springfox.documentation.service.Contact;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * Swagger配置类
 *
 * @author Tanzs
 * @Date 2019/8/20
 */
@Configuration
@EnableSwagger2
public class SwaggerConfig {
    @Bean
    public Docket createRestApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .select()
                //swagger要扫描的包路径
                .apis(RequestHandlerSelectors.basePackage("com.tzs.controller"))
                .paths(PathSelectors.any())
                .build();
    }
    //默认地址：localhost:9191/swagger-ui.html
    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("启梦技术栈 启梦软件管理系统搭建 接口文档")
                .description("用于启梦技术栈公众号  后台管理系统 模块")
                .termsOfServiceUrl("localhost:9191/")
                .contact(new Contact("启梦小Q",null,null))
                .version("1.0")
                .build();
    }
}